<?php

namespace App\Jobs;

use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Log;

class SendWechatMessage implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;

    protected $openid;
    protected $message;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($openid, $message)
    {
        $this->openid = $openid;
        $this->message = $message;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $wechat = app('wechat');

        try{
            $wechat->staff->message($this->message)->to($this->openid)->send();

        } catch (\Exception $e){
        }
    }
}
